﻿using System;

namespace ooWii.Security
{
	public class Content
	{
		#region Content

		public UInt32 ContentID;
		public UInt16 Index;
		public UInt16 Type;
		public UInt64 ContentSize;
		public byte[] Hash;
		SHA1Engine sha1Engine;

		public Content( UInt32 contentId, UInt16 index, UInt16 type, UInt64 contentSize, byte[] hash, SHA1Engine sha1Engine )
		{
			this.ContentID = contentId;
			this.Index = index;
			this.Type = type;
			this.ContentSize = contentSize;
			this.Hash = hash;
			this.sha1Engine = sha1Engine;
		}

		public bool VerifyHash( byte[] buffer )
		{
			byte[] bufferHash = sha1Engine.SHA1.ComputeHash( buffer );

			return SHA1Engine.CompareSHA1( bufferHash, 0, Hash, 0 );
		}

		#endregion
	}
}
